<?php

//$name:  加载文件的命名空间

//tsx 注册自动加载函数
spl_autoload_register(function ($name){
    $name = str_replace('\\',DIRECTORY_SEPARATOR, $name);
    $namespace = explode('/', $name);
    switch ($namespace[0]) {
        case 'think':
           $name = 'Xphp'.DIRECTORY_SEPARATOR.'Xcloze'.DIRECTORY_SEPARATOR.$name;
            break;
            
        case 'JddjOpenApi':
           $name = 'Xphp'.DIRECTORY_SEPARATOR.'Xcloze'.DIRECTORY_SEPARATOR.$name;
            break;
            
        case 'Xcloze':
           $name = 'Xphp'.DIRECTORY_SEPARATOR.$name;
            break;
            
        case 'Enqueue':
           $name = 'Xphp'.DIRECTORY_SEPARATOR.'Xcloze'.DIRECTORY_SEPARATOR.$name;
            break;
            
        case 'Interop':
           $name = 'Xphp'.DIRECTORY_SEPARATOR.'Xcloze'.DIRECTORY_SEPARATOR.$name;
            break;   
            
            
        case 'Bramus':
           $name = 'Xphp'.DIRECTORY_SEPARATOR.'Router'.DIRECTORY_SEPARATOR.$name;
            break; 
        //case 'app':
          // $name = $name;
        //   //如果这个项目下面有公用方法，则加载
        //   if(is_file(SWOOLE_XYH_PATH.$namespace[1].DIRECTORY_SEPARATOR.$namespace[1].DIRECTORY_SEPARATOR.'function.php')){
        //         include_once SWOOLE_XYH_PATH.$namespace[1].DIRECTORY_SEPARATOR.$namespace[1].DIRECTORY_SEPARATOR.'function.php';
        //   }
        
      //  echo $name;
        
     //    $name = 'app'.DIRECTORY_SEPARATOR.'Router'.DIRECTORY_SEPARATOR.$name;
            break; 
        default:
            $name = $name;
            break;
    }
    
    //$name = str_replace('\\',DIRECTORY_SEPARATOR, $name);
    //判断命名空间的所需要加载的类
    
  
    $file = SWOOLE_XYH_PATH.DIRECTORY_SEPARATOR.$name.'.php';
    if(is_file($file)) include_once $file;
});

